package com.holyant.goods.dto;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.domain.BaseDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.Objects;

/**
 * 商品调价申请明细dto
 * 
 * @author fkmalls
 * @date 2022-02-10
 */
@Data
@ApiModel("商品调价申请明细")
public class GdsSkuQuoteItemDto extends BaseDto {

    private static final long serialVersionUID = 1L;

    /** 主表id */
    @Excel(name = "主表id")
    @ApiModelProperty(value = "主表id")
    private Long quoteId;
    /** 报价方式 10：包邮不包税，20：包邮包税，30: 不包邮不包税 */
    @Excel(name = "报价方式 10：包邮不包税，20：包邮包税，30: 不包邮不包税")
    @ApiModelProperty(value = "报价方式 10：包邮不包税，20：包邮包税，30: 不包邮不包税")
    @NotNull(message = "报价方式不能为空")
    private Integer quoteMethod;
    /** skuid */
    @Excel(name = "skuid")
    @ApiModelProperty(value = "skuid")
    private Long skuId;
    /** sku编码 */
    @Excel(name = "sku编码")
    @ApiModelProperty(value = "sku编码")
    @NotNull(message = "sku编码不能为空")
    private String skuCode;
    /** sku名称 */
    @Excel(name = "sku名称")
    @ApiModelProperty(value = "sku名称")
    private String skuName;
    /** 商品id */
    @Excel(name = "商品id")
    @ApiModelProperty(value = "商品id")
    private Long goodsId;
    /** 商品名称 */
    @Excel(name = "商品名称")
    @ApiModelProperty(value = "商品名称")
    private String goodsName;
    /** 商品条码 */
    @Excel(name = "商品条码")
    @ApiModelProperty(value = "商品条码")
    private String goodsBarcode;
    /** 商品编码 */
    @Excel(name = "商品编码")
    @ApiModelProperty(value = "商品编码")
    private String goodsCode;
    /** 分类id */
    @Excel(name = "分类id")
    @ApiModelProperty(value = "分类id")
    private Long categoryId;
    /**  分类编码 */
    @Excel(name = " 分类编码")
    @ApiModelProperty(value = " 分类编码")
    private String categoryCode;
    /** 分类名称 */
    @Excel(name = "分类名称")
    @ApiModelProperty(value = "分类名称")
    private String categoryName;
    /** 计量单位id */
    @Excel(name = "计量单位id")
    @ApiModelProperty(value = "计量单位id")
    private Long unitId;
    /** 计量单位名称 */
    @Excel(name = "计量单位名称")
    @ApiModelProperty(value = "计量单位名称")
    private String unitName;
    /** 毛重 */
    @Excel(name = "毛重")
    @ApiModelProperty(value = "毛重")
    private BigDecimal grossWeigtht;
    /** 净重 */
    @Excel(name = "净重")
    @ApiModelProperty(value = "净重")
    private BigDecimal netWeigtht;
    /** 体积 */
    @Excel(name = "体积")
    @ApiModelProperty(value = "体积")
    private BigDecimal volume;
    /** 规格 */
    @Excel(name = "规格")
    @ApiModelProperty(value = "规格")
    private String specs;
    /** 失效日期 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "失效日期", width = 30, dateFormat = "yyyy-MM-dd")
    @ApiModelProperty(value = "失效日期")
    private LocalDate expireDate;
    /** 箱规 */
    @Excel(name = "箱规")
    @ApiModelProperty(value = "箱规")
    private String boxSpec;
    /** 托规 */
    @Excel(name = "托规")
    @ApiModelProperty(value = "托规")
    private String palletSpec;
    /** 品牌id */
    @Excel(name = "品牌id")
    @ApiModelProperty(value = "品牌id")
    private Long brandId;
    /** 品牌 */
    @Excel(name = "品牌")
    @ApiModelProperty(value = "品牌")
    private String brandName;
    /** 商品扩展 */
    @Excel(name = "商品扩展")
    @ApiModelProperty(value = "商品扩展")
    private String goodsExtAttr;
    /** 币种 */
    @Excel(name = "币种")
    @ApiModelProperty(value = "币种")
    @NotNull(message = "币种不能为空")
    private Integer curType;
    /** 规格数量 */
    @Excel(name = "规格数量")
    @ApiModelProperty(value = "规格数量")
    private Integer specsQty;
    /** 价格 */
    @Excel(name = "价格")
    @ApiModelProperty(value = "价格")
    private String priceObj;
    /** 调整前价格 */
    @Excel(name = "调整前价格")
    @ApiModelProperty(value = "调整前价格")
    private BigDecimal oldPrice;
    /** 调整后价格 */
    @Excel(name = "调整后价格")
    @ApiModelProperty(value = "调整后价格")
    private BigDecimal price;
    /** 价格调整幅度 */
    @Excel(name = "价格调整幅度")
    @ApiModelProperty(value = "价格调整幅度")
    private BigDecimal priceAdjustRange;
    /** 成本价 */
    @Excel(name = "成本价")
    @ApiModelProperty(value = "成本价")
    private BigDecimal costPrice;
    /** $column.columnComment */
    @Excel(name = "成本价")
    @ApiModelProperty(value = "成本价")
    private BigDecimal grossProfit;
    /** 库存 */
    @Excel(name = "库存")
    @ApiModelProperty(value = "库存")
    private BigDecimal stockQty;
    /** 预估新增量 */
    @Excel(name = "预估新增量")
    @ApiModelProperty(value = "预估新增量")
    private BigDecimal estimatedAdditionQty;
    /** 停用标签 */
    @Excel(name = "停用标签")
    @ApiModelProperty(value = "停用标签")
    private String closeFlag;
    /** 描述 */
    @Excel(name = "描述")
    @ApiModelProperty(value = "描述")
    private String remark;
    /** 版本号 */
    @Excel(name = "版本号")
    @ApiModelProperty(value = "版本号")
    private Long ver;

    @ApiModelProperty(value = "删除标识")
    private String delFlag;


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        GdsSkuQuoteItemDto that = (GdsSkuQuoteItemDto) o;
        return Objects.equals(quoteMethod, that.quoteMethod) && Objects.equals(skuId, that.skuId) && Objects.equals(curType, that.curType);
    }

    @Override
    public int hashCode() {
        return Objects.hash(quoteMethod, skuId, curType);
    }

    public JSONObject getSpecsPrice() {
        if (Objects.nonNull(priceObj)) {
            return JSON.parseObject(priceObj);
        }
        return new JSONObject();
    }
}
